package com.example.demo;

import com.example.factory.ProxyFactory;
import com.example.service.OrderService;
import com.example.service.UserService;
import com.example.service.impl.UserServiceImpl;

public class Main {
    public static void main(String[] args) {
        // 测试JDK代理
        UserService userService = new UserServiceImpl();
        UserService userServiceProxy = (UserService) ProxyFactory.createProxy(userService);
        
        System.out.println("测试JDK代理:");
        userServiceProxy.addUser("John Doe");
        
        System.out.println();
        
        // 测试CGLIB代理
        OrderService orderService = new OrderService();
        OrderService orderServiceProxy = (OrderService) ProxyFactory.createProxy(orderService);
        
        System.out.println("测试CGLIB代理:");
        orderServiceProxy.createOrder("ORD-7890");
        orderServiceProxy.queryOrder("ORD-7890");
    }
}